package com.smr.springboot.resttest;

import com.smr.springboot.resttest.interceptor.TestInterceptor;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@SpringBootApplication
public class ResttestApplication {

	public static void main(String[] args) {
		SpringApplication.run(ResttestApplication.class, args);
	}

	/**
	 * 拦截器配置
	 */
	static class WebMvcConfigurer extends WebMvcConfigurerAdapter {
		//增加拦截器
		public void addInterceptors(InterceptorRegistry registry){
			registry.addInterceptor(new TestInterceptor())    //指定拦截器类
					.addPathPatterns("/");        //指定该类拦截的url
		}
	}
}
